<?php if (!defined("_ECRIRE_INC_VERSION")) return;

require_once(_DIR_PLUGIN_ECATALOGUE.'classes/class.CurrencyModel.php');
include_spip('functions/pdk_message');

function formulaires_ecatalogue_currency_traiter_dist($id_currency) {
    $result = array();
    
    $mdl = new CurrencyModel();
    
    if (_request('delete_currency')) {
        
        if ($mdl->delete_by_id($id_currency)) {            
            pdk_set_message_ok(_T('ecatalogue:form_deleted'));
            //$result['message_ok'] = _T('sport:form_deleted');
        } else { 
            pdk_set_message_error(_T('ecatalogue:form_error'));
            //$result['message_erreur'] = _T('sport:form_error');
        }
        include_spip('inc/headers');
        redirige_url_ecrire('ecatalogue_currencies');
    } else { 
        $data = $mdl->form_data_from_array($_REQUEST);                
        if ($mdl->update_by_id($id_currency, $data, true)) {
            $result['message_ok'] = _T('ecatalogue:form_saved');
        } else {
            $result['message_erreur'] = _T('ecatalogue:form_error');
        }    
    }   
    
    return $result;    
}

?>